from unittest import TestCase
from PBOCContaclessUtil import PosProcess, offcard_verify
import os
from datetime import datetime


class ReaderTest(TestCase):

    def _get_log_path(self):
        return os.path.join(
            os.path.abspath(os.path.dirname(__file__)), 'datasamples')

    def _get_log_file(self, prefix: str):
        return os.path.join(self._get_log_path(),
                            '{}_{}'.format(prefix, datetime.now().strftime('%y%m%d%H%M%S.toml')))

    def test_dda(self):
        PosProcess().start(self._get_log_file('SDA_DDA'))

    def test_fdda(self):
        PosProcess().start(self._get_log_file('SDA_fDDA'))
        PosProcess(True).start()

    def test_offcard(self):
        for name in os.listdir(self._get_log_path()):
            if name.endswith('.toml'):
                print('=' * 20 + name + '=' * 20)
                offcard_verify(os.path.join(self._get_log_path(), name))


